package com.naiterui.ehp.bs.wechat.protocol.msg.subscribe;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.naiterui.ehp.bs.wechat.protocol.msg.IPoster;
import lombok.Builder;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;

import java.io.Serializable;
import java.util.Map;

/**
 * 【微信接口协议】订阅通知
 *
 * @author yangfuya
 * @version 1.0
 * @date 2021/4/8 17:16
 **/
@Data
@Builder
public class SubscribeMsg implements IPoster, Serializable {
    private static final long serialVersionUID = -3518109876038302627L;

    /**
     * 接收者（用户）的 openid
     */
    @JsonProperty("touser")
    private String toUser;
    /**
     * 所需下发的订阅模板id
     */
    @JsonProperty("template_id")
    private String templateId;
    /**
     * 跳转网页时填写
     */
    private String page;
    /**
     * 跳转小程序时填写，格式如{ "appid": "pagepath": { "value": any } }
     */
    @JsonProperty("miniprogram")
    private SubscribeMp miniProgram;
    /**
     * 模板内容，格式形如 { "key1": { "value": any }, "key2": { "value": any } }
     */
    private Map<String, Data> data;

    public static class Data {
        private Object value;

        public Data(Object value) {
            this.value = value;
        }

        public Object getValue() {
            return value;
        }

        public void setValue(Object value) {
            this.value = value;
        }

        @Override
        public String toString() {
            return ToStringBuilder.reflectionToString(this);
        }
    }
}
